home *** CD-ROM | disk | FTP | other *** search
- (*$C-,B-,U-,V-,R-,D+ *)
- Program PibList;
-
- (*----------------------------------------------------------------------*)
- (* PibList --- Turbo Pascal Ascii File Listing Program *)
- (*----------------------------------------------------------------------*)
- (* *)
- (* Author: Philip R. Burns *)
- (* Date: March, 1985 *)
- (* Version: 1.0 *)
- (* Systems: For MS-DOS on IBM PCs and close compatibles only. *)
- (* Note: I have checked these on Zenith 151s under *)
- (* MSDOS 2.1 and IBM PCs under PCDOS 2.0. *)
- (* *)
- (* NOTE: THIS PROGRAM REQUIRES TURBO 3.0 OR LATER! *)
- (* *)
- (* Overview: PibList will list an ascii file on the PC's screen. *)
- (* It combines most of the features found in other "browse" *)
- (* programs: *)
- (* *)
- (* -- Absolute and relative line numbers, screens, and *)
- (* pages. *)
- (* *)
- (* -- Very large file capability (any size file can be *)
- (* listed). *)
- (* *)
- (* -- A string search facility. *)
- (* *)
- (* -- Pages can be defined by a FF (Ascii 12) character, *)
- (* or by ANSI carriage control '1' in column 1. *)
- (* *)
- (* -- Support for color graphics screen if available. *)
- (* *)
- (* -- Horizontal tab expansion. *)
- (* *)
- (* -- High-order bit stripping. *)
- (* *)
- (* Document: The file PIBLIST.DOC describes program usage in detail. *)
- (* *)
- (*----------------------------------------------------------------------*)
- (* *)
- (* Suggestions for improvements or corrections are welcome. *)
- (* Please leave messages on Gene Plantz's BBS (312) 882 4227 *)
- (* or Ron Fox's BBS (312) 940 6496. *)
- (* *)
- (* I hope that you find this program useful -- and, *)
- (* if you expand upon it, please upload your extensions so *)
- (* that all of us can enjoy them! *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- (*$IPIBLIST.DOC*)
-
- (* Constant and type declarations *)
-
- (*$IGLOBTYPE.PAS*)
-
- CONST
-
- Max_String = 255 (* max string length *);
- Height = 24 (* list window Height *);
- Max_buf_lines = 100 (* max number of lines in buffer *);
- Max_buf_pages = 5 (* max number of pages in buffer *);
- FF = #12 (* form feed character *);
- TAB = #9 (* tab character *);
- CR = #13 (* carriage return character *);
- LF = #10 (* line feed character *);
- ESC = #27 (* escape character *);
- NUL = #0 (* null character *);
- Ctrlx = ^X (* line delete character *);
- BS = #8 (* backspace character *);
- Buffer_Size = 8191 (* Buffer size for input file *);
- Screen_Size = 3936 (* Size of screen memory area *)
- (* -- First 24 lines of 80 only *);
-
- (* Color/mono screen addresses *)
-
- Color_Screen_Address = $B800;
- Mono_Screen_Address = $B000;
-
-
- TYPE
-
- Line_Ptr = ^Line (* pointer to text line *);
-
- Line = (* text line *)
- RECORD
- Next: Line_Ptr (* pointer to next line in buffer *);
- Lnum: REAL (* line number *);
- Pnum: REAL (* page number *);
- Txt: AnyStr (* text Line *);
- END;
-
- CHAR6 = STRING[6];
-
- Fib_Record = RECORD (* text file interface block *)
- Handle: INTEGER;
- Flags: BYTE;
- CurCh: CHAR;
- BufOff: INTEGER;
- BufSize: INTEGER;
- BufPtr: INTEGER;
- BufEnd: INTEGER;
- END;
-
- Fib_Ptr = ^Fib_Record;
-
- Buffer_Type = PACKED ARRAY[0..Buffer_Size] OF CHAR;
-
- Buffer_Ptr = ^Buffer_Type;
-
- Screen_Type = ARRAY[ 1 .. Screen_Size ] OF CHAR;
-
- Screen_Ptr = ^Screen_Type;
-
-
- (* Structured *) CONST
- (* names for special chars *)
-
- Spec_Names: ARRAY [#0..#31] OF CHAR6
-
- = ('<NUL> ', '<SOH> ', '<STX> ', '<ETX> ',
- '<EOT> ', '<ENQ> ', '<ACK> ', '<BEL> ',
- '<BS> ', '<HT> ', '<LF> ', '<VT> ',
- '<FF> ', '<CR> ', '<SO> ', '<SI> ',
- '<DLE> ', '<DC1> ', '<DC2> ', '<DC3> ',
- '<DC4> ', '<NAK> ', '<SYN> ', '<ETB> ',
- '<CAN> ', '<EM> ', '<SUB> ', '<ESC> ',
- '<FS> ', '<GS> ', '<RS> ', '<US> ');
-
- (* Variable declarations *)
-
- VAR
-
- F: TEXT [Buffer_Size] (* file to be listed *);
- F_Ptr: Fib_Ptr (* pointer to text file FIB *);
- First: Line_Ptr (* pointer to first line in buffer *);
- Last: Line_Ptr (* pointer to last line in buffer, *)
- (* or nil if buffer empty *);
- Top: Line_Ptr (* pointer to top line in viewing window *);
- Bot: Line_Ptr (* pointer to bottom line in viewing *)
- (* window *);
- Cur_line: REAL (* line number of next line on file f *);
- Cur_page: REAL (* page number of next line on file f *);
- Max_line: REAL (* max line number seen so far *);
- Max_page: REAL (* max page number seen so far *);
- (* command line *)
- Command: PACKED ARRAY[1..Max_String] OF CHAR;
- Cind: INTEGER (* current position in command line *);
- First_col: INTEGER (* first col to be displayed *);
- Width: INTEGER (* screen width *);
- Lpt: BOOLEAN (* TRUE if f has line printer carriage *)
- (* control *);
- Nocc: BOOLEAN (* TRUE if f has no carriage control *);
- Eject_Char: CHAR (* '1' if lpt, else <FF> *);
- Done: BOOLEAN (* TRUE when time to quit *);
- Eod: BOOLEAN (* TRUE if requested line or page *)
- (* is beyond end of file f *);
- Eof_seen: BOOLEAN (* TRUE if eof reached *);
- Top_line: REAL (* line number of top line on currently *)
- (* displayed screen *);
- One_Up: BOOLEAN (* If command is move up one line *);
- One_Down: BOOLEAN (* If command is move down one line *);
- Search_Str: AnyStr (* String to look for with search comm. *);
- Search_Lpos: INTEGER (* Screen position of line containing *)
- (* searched string *);
- Search_Line: REAL (* Line number of line containing *)
- (* searched string *);
- Search_Col: INTEGER (* Position of searched string in line *);
- Spec_Chars: SET OF CHAR (* unprintable characters *);
- Real_Screen: Screen_Ptr (* Address of screen memory *);
- My_Screen : Screen_Type (* Area in which screen image is built *);
- Strip_High : BOOLEAN (* TRUE to strip high-order bits *);
- Expand_Tabs: BOOLEAN (* TRUE to expand horizontal tabs *);
-
- (*--------------------------------------------------------------------------*)
- (* Global Color Variables *)
- (*--------------------------------------------------------------------------*)
-
- Var
-
- ForeGround_Color : INTEGER (* Color for ordinary text *);
- BackGround_Color : INTEGER (* Usual background color *);
-
- Help_Text_Color : INTEGER (* Color for help text *);
- Spec_Chars_Color : INTEGER (* Color for special/control chars *);
- Status_Line_Color: INTEGER (* Color for status line *);
- Search_Text_Color: INTEGER (* Color for searched text *);
-
- (*$IMINMAX.PAS *)
- (*$ISETCOLOR.PAS *)
- (*$ISCREENLO.PAS *)
- (*$ICLEARSCR.PAS *)
- (*$IRESETF.PAS *)
- (*$IREADLNF.PAS *)
- (*$ICLEARBUF.PAS *)
- (*$ISKIPS.PAS *)
- (*$IREADLINE.PAS *)
- (*$IFIND.PAS *)
- (*$IFORMATLI.PAS *)
- (*$IDISPLAYS.PAS *)
- (*$IDISPLAYM.PAS *)
- (*$INUMBER.PAS *)
- (*$ISKIPBL.PAS *)
- (*$IISSUEPRO.PAS *)
- (*$IREADCOMM.PAS *)
- (*$IPOSITION.PAS *)
- (*$IPROMPT.PAS *)
- (*$IINIT.PAS *)
-
- (*--------------------------------------------------------------------------*)
- (* PIBLIST -- Main Program *)
- (*--------------------------------------------------------------------------*)
-
- (*--------------------------------------------------------------------------*)
- (* *)
- (* The main program initializes everything, and then repeatedly *)
- (* displays screens and prompts until an E command is entered. *)
- (* On termination the screen is cleared. *)
- (* *)
- (*--------------------------------------------------------------------------*)
-
- BEGIN (* PibList -- Main Program *)
-
- Initialize;
-
- WHILE ( NOT done ) DO
- BEGIN
- Display_Screen;
- Prompt;
- END;
-
- Clear_Screen;
-
- END (* PibList *).